/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class TransactionTotals
    {
    
        private  Price totalField;
        private  Price subtotalField;
        private  Price taxField;
        private  Price shippingChargeField;
        private  Price promotionField;

        /// <summary>
        /// Gets and sets the Total property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Total")]
        public Price Total
        {
            get { return this.totalField ; }
            set { this.totalField = value; }
        }



        /// <summary>
        /// Sets the Total property
        /// </summary>
        /// <param name="total">Total property</param>
        /// <returns>this instance</returns>
        public TransactionTotals WithTotal(Price total)
        {
            this.totalField = total;
            return this;
        }



        /// <summary>
        /// Checks if Total property is set
        /// </summary>
        /// <returns>true if Total property is set</returns>
        public Boolean IsSetTotal()
        {
            return this.totalField != null;
        }




        /// <summary>
        /// Gets and sets the Subtotal property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Subtotal")]
        public Price Subtotal
        {
            get { return this.subtotalField ; }
            set { this.subtotalField = value; }
        }



        /// <summary>
        /// Sets the Subtotal property
        /// </summary>
        /// <param name="subtotal">Subtotal property</param>
        /// <returns>this instance</returns>
        public TransactionTotals WithSubtotal(Price subtotal)
        {
            this.subtotalField = subtotal;
            return this;
        }



        /// <summary>
        /// Checks if Subtotal property is set
        /// </summary>
        /// <returns>true if Subtotal property is set</returns>
        public Boolean IsSetSubtotal()
        {
            return this.subtotalField != null;
        }




        /// <summary>
        /// Gets and sets the Tax property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Tax")]
        public Price Tax
        {
            get { return this.taxField ; }
            set { this.taxField = value; }
        }



        /// <summary>
        /// Sets the Tax property
        /// </summary>
        /// <param name="tax">Tax property</param>
        /// <returns>this instance</returns>
        public TransactionTotals WithTax(Price tax)
        {
            this.taxField = tax;
            return this;
        }



        /// <summary>
        /// Checks if Tax property is set
        /// </summary>
        /// <returns>true if Tax property is set</returns>
        public Boolean IsSetTax()
        {
            return this.taxField != null;
        }




        /// <summary>
        /// Gets and sets the ShippingCharge property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ShippingCharge")]
        public Price ShippingCharge
        {
            get { return this.shippingChargeField ; }
            set { this.shippingChargeField = value; }
        }



        /// <summary>
        /// Sets the ShippingCharge property
        /// </summary>
        /// <param name="shippingCharge">ShippingCharge property</param>
        /// <returns>this instance</returns>
        public TransactionTotals WithShippingCharge(Price shippingCharge)
        {
            this.shippingChargeField = shippingCharge;
            return this;
        }



        /// <summary>
        /// Checks if ShippingCharge property is set
        /// </summary>
        /// <returns>true if ShippingCharge property is set</returns>
        public Boolean IsSetShippingCharge()
        {
            return this.shippingChargeField != null;
        }




        /// <summary>
        /// Gets and sets the Promotion property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Promotion")]
        public Price Promotion
        {
            get { return this.promotionField ; }
            set { this.promotionField = value; }
        }



        /// <summary>
        /// Sets the Promotion property
        /// </summary>
        /// <param name="promotion">Promotion property</param>
        /// <returns>this instance</returns>
        public TransactionTotals WithPromotion(Price promotion)
        {
            this.promotionField = promotion;
            return this;
        }



        /// <summary>
        /// Checks if Promotion property is set
        /// </summary>
        /// <returns>true if Promotion property is set</returns>
        public Boolean IsSetPromotion()
        {
            return this.promotionField != null;
        }






        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetTotal()) {
                Price  total = this.Total;
                xml.Append("<Total>");
                xml.Append(total.ToXMLFragment());
                xml.Append("</Total>");
            } 
            if (IsSetSubtotal()) {
                Price  subtotal = this.Subtotal;
                xml.Append("<Subtotal>");
                xml.Append(subtotal.ToXMLFragment());
                xml.Append("</Subtotal>");
            } 
            if (IsSetTax()) {
                Price  tax = this.Tax;
                xml.Append("<Tax>");
                xml.Append(tax.ToXMLFragment());
                xml.Append("</Tax>");
            } 
            if (IsSetShippingCharge()) {
                Price  shippingCharge = this.ShippingCharge;
                xml.Append("<ShippingCharge>");
                xml.Append(shippingCharge.ToXMLFragment());
                xml.Append("</ShippingCharge>");
            } 
            if (IsSetPromotion()) {
                Price  promotion = this.Promotion;
                xml.Append("<Promotion>");
                xml.Append(promotion.ToXMLFragment());
                xml.Append("</Promotion>");
            } 
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}